using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using Voodoo.Sauce.Internal.Analytics;

namespace Voodoo.Sauce.Debugger
{
	public class EventConsoleItem : MonoBehaviour
	{
		[SerializeField]
		private Text eventNameText;

		[SerializeField]
		private Text details;

		[SerializeField]
		private Text timestamp;

		[SerializeField]
		private GameObject sendingStatus;

		[SerializeField]
		private GameObject sentStatus;

		[SerializeField]
		private GameObject errorStatus;

		[SerializeField]
		private Button infoButton;

		internal void UpdateData(DebugAnalyticsLog log, UnityAction infoAction)
		{
			eventNameText.text = log.EventName;
			details.text = log.AdditionalInformation;
			timestamp.text = log.Timestamp.ToLongTimeString();
			switch (log.StateEnum)
			{
			case DebugAnalyticsStateEnum.ForwardedTo3rdParty:
				sendingStatus.SetActive(value: true);
				sentStatus.SetActive(value: false);
				errorStatus.SetActive(value: false);
				break;
			case DebugAnalyticsStateEnum.Sent:
				sendingStatus.SetActive(value: false);
				sentStatus.SetActive(value: true);
				errorStatus.SetActive(value: false);
				break;
			case DebugAnalyticsStateEnum.ErrorSending:
			case DebugAnalyticsStateEnum.SentButErrorFromServer:
			case DebugAnalyticsStateEnum.Error:
				sendingStatus.SetActive(value: false);
				sentStatus.SetActive(value: false);
				errorStatus.SetActive(value: true);
				break;
			}
			if (infoAction != null)
			{
				infoButton.onClick.RemoveAllListeners();
				infoButton.onClick.AddListener(infoAction);
			}
		}
	}
}
